class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int left, right = 0;
        int res = 0;
        int arr[128] = { 0 };
        while (right < s.length())
        {
            arr[s[right]]++;
            while (arr[s[right]] > 1)
            {
                arr[s[left]]--;
                left++;
            }
            res = max(res, right - left + 1);
            right++;
        }
        return res;
    }
};